import { WeaBrowser, WeaSelect } from 'ecCom';
import { HtmlType } from "../../../../constants/excel";

export default class FieldType extends React.Component {
    render() {
        const { htmlType } = this.props;
        if (htmlType === HtmlType.Input || htmlType === HtmlType.Browser) {
            return (
                <div className="ant-row">
                    <label>数据类型</label>
                    {this.getSelect(this.props)}
                </div>
            );
        }
        return null;
    }
    getSelect = ({ htmlType, ...props }) => {
        if (htmlType === HtmlType.Input) {
            return (
                <WeaSelect
                    options={[{
                        key: 'text',
                        showname: '文本'
                    }, {
                        key: 'int',
                        showname: '整数'
                    }, {
                        key: 'float',
                        showname: '浮点数'
                    }]}
                    {...props}
                />
            )
        } else if (htmlType === HtmlType.Browser) {
            const { style, value, disabled, ...restProps } = props;
            return (
                <WeaBrowser
                    mask
                    type={'browserTypeList'}
                    inputStyle={style}
                    {...restProps}
                    viewAttr={disabled ? 1 : 3}
                    hasBorder={true}
                    replaceDatas={value.valueObj ? value.valueObj : value.value && [{ id: value.value, name: value.valueSpan }]}
                />
            )
        }
    }
}